package com.liyuan.yiqixing.service.impl;

import com.liyuan.yiqixing.dao.SignupDao;
import com.liyuan.yiqixing.model.Signup;
import com.liyuan.yiqixing.service.SignupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SignupServiceImpl implements SignupService {
    @Autowired
    SignupDao signupDao;

    @Override
    public Integer checkIsAlreadySignup(Integer userid, Integer itemId) {
        return signupDao.selectSignupId(userid,itemId);
    }

    @Override
    public void signup(Integer userId, Integer itemId,Integer hostelId) {

        signupDao.signup(userId,itemId,hostelId);
    }

    @Override
    public Signup[] retrieveSignupInfos(Integer userId) {
        Signup[] signups = signupDao.selectSignupInfos(userId);
        return signups;
    }

    @Override
    public Signup[] retrieveSignupInfosByHostelId(Integer hostelId) {
        Signup[] signups = signupDao.selectSignupInfosByHostelId(hostelId);
        return signups;
    }

    @Override
    public void updateSignupStatusToNotAccept(Integer signupId) {
        signupDao.updateSignupStatusToNotAccept(signupId);
    }
    @Override
    public void updateSignupStatusToAccept(Integer signupId) {
        signupDao.updateSignupStatusToAccept(signupId);
    }
}
